// my-app/src/app/userManage/[id]/page.js
// import { cookies } from 'next/headers';
// import { fetchUserById } from '@/util/actions/userAction';
// import EditUserClient from './EditUserClient';

// export default async function EditUserPage({ params }) {
//   const { id } = params;
//   const cookieStore = cookies();
//   const token = cookieStore.get("token")?.value;

//   if (!token) {
//     throw new Error("No token found");
//   }

//   const userData = await fetchUserById(token);

//   return <EditUserClient user={userData} />;
// }

// my-app/src/app/userManage/[id]/page.js
import { cookies } from 'next/headers';
import { fetchUserById } from '@/util/actions/userAction';
import EditUserClient from './EditUserClient';

export default async function EditUserPage({ params }) {
  const { id } = params;
  const cookieStore = cookies();
  const tokenCookie = cookieStore.get("token");

  if (!tokenCookie) {
    throw new Error("No token found");
  }

  const token = tokenCookie.value;
  const userData = await fetchUserById(token);

  return <EditUserClient user={userData} token={token} />;
}
